package com.gtis.demo.core.view;


import com.lowagie.text.Document;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.view.document.AbstractPdfView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author <a href="mailto:xingxiao@gtmap.cn">xingxiaofeng</a>
 * @version2.1 2020/7/30
 * @description
 */


public class GtMapPdfView  extends AbstractPdfView {
    Logger logger= LoggerFactory.getLogger(this.getClass());
    public static final String DATA = "data";
    public static final String FILENAME = "mergePdfFileName";


    protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String,String> userData = (Map<String,String>) model.get("data");

        Table table = new Table(2);
        table.addCell("Roll No");
        table.addCell("Name");

        for (Map.Entry<String, String> entry : userData.entrySet()) {
            table.addCell(entry.getKey());
            table.addCell(entry.getValue());
        }
        document.add(table);

    }

}
